import axios from 'axios'

// 创建axios实例
var instance = axios.create({timeout: 1000 * 12})
instance.interceptors.request.use(
  config => {
    console.log('发送请求')
    if (window.sessionStorage.getItem('token')) {
      // console.log('请求头加入token')
      config.headers.token = window.sessionStorage.getItem('token')
    }
    return config
  },
  error => {
    return Promise.error(error)
  }
)

export default instance
